package com.bw.car.view

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import androidx.lifecycle.ReportFragment.Companion.reportFragment
import androidx.recyclerview.widget.LinearLayoutManager
import com.alibaba.android.arouter.facade.annotation.Autowired
import com.alibaba.android.arouter.facade.annotation.Route
import com.alibaba.android.arouter.launcher.ARouter
import com.bw.base.constants.RoutePath

import com.bw.car.adapter.PackPayAdapter
import com.bw.car.databinding.ActivityCarBinding
import com.bw.car.entity.PackPayEntity
import com.bw.car.inter.Click
import com.bw.car.net.CarViewModel
import com.bw.common.view.BaseMvvmActivity

@Route(path = RoutePath.PATH_CAR)
class CarActivity : BaseMvvmActivity<ActivityCarBinding,CarViewModel>() {


    private lateinit var payAdapter: PackPayAdapter

//
//    @Autowired
//    private lateinit var park:PackPayEntity


    override fun initView() {
        binding.topBar.tvTitle.text = "车辆管理"
        binding.topBar.ivBack.setOnClickListener { finish() }

        payAdapter = PackPayAdapter()
        binding.rvCar.adapter = payAdapter
        binding.rvCar.layoutManager = LinearLayoutManager(this)

        payAdapter.setItemClick(object  :Click<PackPayEntity>{
            override fun onCLick(item: PackPayEntity, position: Int) {
                ARouter.getInstance().build(RoutePath.PATH_CAR_EDIT).navigation()

            }
        })

        binding.llAdd.setOnClickListener {
            ARouter.getInstance().build(RoutePath.PATH_UPDATE_CAR).navigation()
        }





    }

    override fun initData() {
        vm.packPaySuccess.observe(this){
            payAdapter.data.clear()
            payAdapter.data.addAll(it)
            payAdapter.notifyDataSetChanged()
        }

    }

    override fun onResume() {
        super.onResume()
        vm.getPackPay()
    }

//    override fun onCreate(savedInstanceState: Bundle?) {
//        ARouter.getInstance().inject(this)
//        super.onCreate(savedInstanceState)
//    }

}